﻿using UnityEngine;
using System.Collections.Generic;
using System.Collections;
using System;

namespace Project
{
    public enum E_Operator : byte
    {
        Add, Sub, Mul, Div, And, Or, Not,
    }
    [Serializable]
    public class BuffConfig
    {
        /// <summary>
        /// 是否可以提升层级 一些buff会产生叠加效果
        /// </summary>
        [field: SerializeField] public bool IsStackable { get; private set; }
        /// <summary>
        /// Buff的 ID 枚举
        /// </summary>
        [field: SerializeField] public BuffID ID { get; private set; }
        /// <summary>
        /// Buff的 运算 枚举
        /// </summary>
        [field: SerializeField] public E_Operator Op { get; private set; }
        /// <summary>
        /// 如果持续时间为 0 说明是永久buff
        /// </summary>
        [field: SerializeField] public float Duration { get; private set; }
        /// <summary>
        /// Buff 的 触发间隔
        /// </summary>
        [field: SerializeField] public float TriggerInterval { get; private set; }
        /// <summary>
        /// Buff 的 Icon 图
        /// </summary>
        [Framework.PnShowSprite] public Sprite sprite;
        [SerializeField][Multiline()] private string mDescription;
        public string Description => mDescription;
        /// <summary>
        /// 计时持续buff
        /// </summary>
        public bool IsTimeBuff => Duration > 0;
        /// <summary>
        /// 被动Buff
        /// </summary>
        public bool IsPassive => TriggerInterval == 0;
    }
    [CreateAssetMenu(fileName = "New BuffConfig", menuName = "Data/SO/BuffConfig")]
    public class SO_BuffConfig : ScriptableObject, IEnumerable<BuffConfig>
    {
        [SerializeField] private BuffConfig[] Datas;

        IEnumerator<BuffConfig> IEnumerable<BuffConfig>.GetEnumerator()
        {
            for (int i = 0; i < Datas.Length; i++)
            {
                yield return Datas[i];
            }
        }
        IEnumerator IEnumerable.GetEnumerator()
        {
            for (int i = 0; i < Datas.Length; i++)
            {
                yield return Datas[i];
            }
        }
    }
}